package com.rq.adapter;

import android.view.View;
import android.widget.Toast;

import com.rq.rvlibrary.BaseAdapter;
import com.rq.rvlibrary.BaseViewHolder;
import com.rq.rvlibrary.OnClick;
import com.rq.rvlibrary.OnInterceptClick;

public class HeadViewHolder extends BaseViewHolder implements OnInterceptClick {

  @Override
  @OnClick({R.id.txt_left, R.id.txt_right})
  public boolean intercept(Object object, View v, int position) {
    if (v.getId() == R.id.txt_left) {
      Toast.makeText(v.getContext(), "LEFT", Toast.LENGTH_LONG).show();
    } else if (v.getId() == R.id.txt_right) {
      Toast.makeText(v.getContext(), "RIGHT", Toast.LENGTH_LONG).show();
    }
    return false;
  }

  public static class DebugData {
    public DebugData(boolean isLeft, String realContent) {
      this.isLeft = isLeft;
      this.realContent = realContent;
    }

    boolean isLeft = false;
    String realContent;
  }

  public HeadViewHolder(View itemView) {
    super(itemView);

  }

  @Override
  public int inflateLayoutId() {
    return R.layout.item_head_view;
  }

  @Override
  public void fillData(BaseAdapter adapter, int position, Object data) {
    super.fillData(adapter, position, data);
    LOG.e("HeadViewHolder", "fillData.54:" + position);
    if (data instanceof DebugData) {
      DebugData bean = (DebugData) data;
      if (bean.isLeft) {
        setItemText(R.id.txt_left, position + "." + bean.realContent);
      } else {
        setItemText(R.id.txt_right, position + "." + bean.realContent);
      }
    }
  }

}
